const mongoose = require('mongoose')

const db = mongoose.connection

// 权限登录 连接数据库
mongoose.connect('mongodb://admin:123456@127.0.0.1:27017/test?authSource=admin', {
	useNewUrlParser: true,
	useUnifiedTopology: true
})
db.on('error', console.error.bind(console, 'connection error:'))

const stuSchema = mongoose.Schema({
	name: String,
	age: Number,
	sex: Number
})

const Stu = mongoose.model('stus', stuSchema)

module.exports = { Stu }
